<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>弹出提示框的 try...catch 语句</title>
</head>

<body>
    <script>
        var txt = "";
        function message() {
            try {
                addlert("fucl");
            }
            catch (err) {
                txt = "此页面出错。\n\n";
                txt += "单击“确定”继续查看此页面，\n";
                txt += "或者取消返回主页。\n\n"
                if (!confirm(txt)) {
                    document.location.href = "http://www.w3school.com.cn/";
                }
            }
        }
    </script>
    <input type="button" value="查看消息" onclick="message()" />
</body>

</html>